package org.example.controller;

import jakarta.annotation.Resource;
import org.example.entity.RestBean;
import org.example.entity.dto.Forum;
import org.example.entity.vo.response.AccountExtendVO;
import org.example.service.ForumService;
import org.example.service.RsAccountForumService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/rs-af")
public class ForumDetailController {
    @Resource
    RsAccountForumService rsAccountForumService;
    @Resource
    ForumService forumService;

    @GetMapping("/detail")
    public RestBean<Map<String, Object>> detail(@RequestParam("forumID") Integer forumID) {
        HashMap<String, Object> ans = new HashMap<>();
        Forum forum = forumService.getById(forumID);
        AccountExtendVO forumLeaderInfo = rsAccountForumService.getForumLeaderInfo(forumID);
        ans.put("forum", forum);
        ans.put("forumLeaderInfo", forumLeaderInfo);
        return RestBean.success(ans);
    }
}
